/*
* LinearComplexity.h
* Last edited: 21.07.2014
* Author: David Noack
*/

#pragma once
#include "NistTest.h"
#include <boost\math\special_functions\gamma.hpp>

/**
\class LinearComplexity
\brief Implementation of the Nist LinearComplexity-test
*/
class LinearComplexity : public NistTest
{

	public:
		/** Constructor
		\param bitArray Represents the random bits which have to be tesed.
		\param bitArraySize The size of bitArry in bits.*/
		LinearComplexity(bool* bitArray, int bitArraySize);

		/**Destructor*/
		~LinearComplexity(){};

		/**Does nothing in LinearComplexity*/
		void start(){};

		/**Executes the LinearComplexity-test at the bitArray, given by the constructor.
		\param blockSize The size one block within the bitArray
		\param size The number of bits you want to test within the bitArray.*/
		double execute(int blockSize, int size);

	private:

		/**Implementation of the Berlekamp-Massey algorithm*/
		double computeLFSR();
		
		/**expected probabilitys*/
		static double pi[7];

		/**Chi Square Distribution*/
		double chi_square;
		/**degree of freedom.Hard coded as 6 but no further information in the NIST doc*/
		int K;
		/** Number of Blocks*/
		int numberOfBlocks; 
		/** The size of one block*/
		int blocksize;

		short* c;
		short* t;
		short* b;
		short* p;

		/** Classes of the differnt LFSR*/
		int v[7];
		
};

